package TestExercises01;

import java.util.Random;

//开发验证码————前4位为字母，后1位为数字
public class test03 {
    public static void main(String[] args) {
        char[] chs = new char[52];
        for (int i = 0; i < chs.length; i++) {
            if (i <= 25) {
                chs[i] = (char) (97 + i);//A~Z
            } else {
                chs[i] = (char) (65 + i - 26);//a~z
            }
        }

        String result = "";
        Random r = new Random();
        for (int i = 0; i < 4; i++) {
            int randomIndex = r.nextInt(52);
            result = result + chs[randomIndex];
        }
        int number = r.nextInt(10);
        result = result + number;

        System.out.println("最终验证码为：" + result);
    }
}
